home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / vol16n12.zip / IPC.ZIP / THROW.ZIP / THROWDLG.CPP < prev    next >
C/C++ Source or Header  |  1997-02-12  |  2KB  |  105 lines

  1. // ThrowDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Throw.h"
  6. #include "ThrowDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CThrowDlg dialog
  16.  
  17. CThrowDlg::CThrowDlg(CWnd* pParent /*=NULL*/)
  18.     : CDialog(CThrowDlg::IDD, pParent)
  19. {
  20.     //{{AFX_DATA_INIT(CThrowDlg)
  21.     //}}AFX_DATA_INIT
  22.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  23.     m_hIcon = AfxGetApp()->LoadStandardIcon(IDI_WINLOGO);
  24. }
  25.  
  26. void CThrowDlg::DoDataExchange(CDataExchange* pDX)
  27. {
  28.     CDialog::DoDataExchange(pDX);
  29.     //{{AFX_DATA_MAP(CThrowDlg)
  30.     DDX_Control(pDX, IDC_EDIT, m_wndEdit);
  31.     //}}AFX_DATA_MAP
  32. }
  33.  
  34. BEGIN_MESSAGE_MAP(CThrowDlg, CDialog)
  35.     //{{AFX_MSG_MAP(CThrowDlg)
  36.     ON_WM_PAINT()
  37.     ON_WM_QUERYDRAGICON()
  38.     ON_BN_CLICKED(IDC_SEND, OnSend)
  39.     //}}AFX_MSG_MAP
  40.     ON_BN_CLICKED (IDOK, OnSend)
  41. END_MESSAGE_MAP()
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CThrowDlg message handlers
  45.  
  46. BOOL CThrowDlg::OnInitDialog()
  47. {
  48.     CDialog::OnInitDialog();
  49.  
  50.     SetIcon(m_hIcon, TRUE);            // Set big icon
  51.     SetIcon(m_hIcon, FALSE);        // Set small icon
  52.     
  53.     return TRUE;
  54. }
  55.  
  56. void CThrowDlg::OnPaint() 
  57. {
  58.     if (IsIconic())
  59.     {
  60.         CPaintDC dc(this);
  61.  
  62.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  63.  
  64.         // Center icon in client rectangle
  65.         int cxIcon = GetSystemMetrics(SM_CXICON);
  66.         int cyIcon = GetSystemMetrics(SM_CYICON);
  67.         CRect rect;
  68.         GetClientRect(&rect);
  69.         int x = (rect.Width() - cxIcon + 1) / 2;
  70.         int y = (rect.Height() - cyIcon + 1) / 2;
  71.  
  72.         // Draw the icon
  73.         dc.DrawIcon(x, y, m_hIcon);
  74.     }
  75.     else
  76.     {
  77.         CDialog::OnPaint();
  78.     }
  79. }
  80.  
  81. HCURSOR CThrowDlg::OnQueryDragIcon()
  82. {
  83.     return (HCURSOR) m_hIcon;
  84. }
  85.  
  86. void CThrowDlg::OnSend() 
  87. {
  88.     CString string;
  89.     m_wndEdit.GetWindowText (string);
  90.  
  91.     TCHAR* pString = new TCHAR[string.GetLength () + 1];
  92.     ::lstrcpy (pString, (LPCTSTR) string);
  93.  
  94.     if (!string.IsEmpty ()) {
  95.         CWnd* pWnd = CWnd::FindWindow (NULL, "Catch");
  96.         if (pWnd != NULL) {
  97.             COPYDATASTRUCT cds;
  98.             cds.dwData = string.GetLength () + 1;
  99.             cds.cbData = (string.GetLength () + 1) * sizeof (TCHAR);
  100.             cds.lpData = (PVOID) pString;
  101.             pWnd->SendMessage (WM_COPYDATA, (WPARAM) m_hWnd, (LPARAM) &cds);
  102.         }
  103.     }    
  104. }
  105.